//
//  ZMConst.swift
//  ZMBaseModule
//
//  Created by Rowling on 2020/5/25.
//  Copyright © 2020 Rowling. All rights reserved.
//

import Foundation
@_exported import RxCocoa
@_exported import RxSwift
@_exported import SnapKit
@_exported import HandyJSON
@_exported import Then

import UIKit

/** 屏幕宽*/
let SCREEN_W = UIScreen.main.bounds.width
/** 屏幕高*/
let SCREEN_H = UIScreen.main.bounds.height
/** 屏幕大小*/
let SCREEN_BOUNDS = UIScreen.main.bounds
/** status bar高*/
let STATUS_HEIGHT = UIApplication.shared.statusBarFrame.maxY
/** 导航栏高度*/
let NAV_HEIGHT : CGFloat = 44.0
/** 导航+statust bar 高*/
let StaNavBarH = CGFloat(STATUS_HEIGHT) + CGFloat(NAV_HEIGHT)
/** appwindow*/
let APPWindow = UIApplication.shared.keyWindow
/** 是否是iphoneX*/
let isIphoneX = UIApplication.shared.statusBarFrame.maxY > 20
/** 底部距离*/
var BottomSpace : CGFloat = isIphoneX ? 34.0 : 0.0
/** tabbar*/
let TabbarHeight : CGFloat = 49
/** 获取系统版本*/
let IOS_SYSTEM_VERSION = Float(UIDevice.current.systemVersion)!
/** 获取设备id*/
let ZM_DefUUID = UIDevice.current.identifierForVendor?.uuidString
/** 获取 plist版本号*/
let AppVersion = (Bundle.main.infoDictionary!["CFBundleShortVersionString"] as? String)!
/** 获取 build版本号*/
let AppBuildVersion = (Bundle.main.infoDictionary!["CFBundleVersion"] as? String)!
/** 获取 plist name*/
let AppName = (Bundle.main.infoDictionary!["CFBundleName"] as? String)!

func rpx(_ x: CGFloat) -> CGFloat {
    return floor(SCREEN_W / (375.0 / x) * 10) / 10
}

let YMD = "YYYY-MM-dd"
let YMDHM = "YYYY-MM-dd HH:mm"
let YMDHMS = "YYYY-MM-dd HH:mm:ss"

let defaut_color = UIColor.zm.color(hexString: Style.mainColorStr)

let nav_color = UIColor.zm.color(hexString: "#441619")

/** 自定义print*/
public func ZMLog<T>(message: T,
                 file: String   = #file,
                 method: String = #function,
                 line: Int      = #line){
    #if DEBUG
    print("\((file as NSString).lastPathComponent)[\(line)], \(method): \(message)")
    #endif
}

/**阿里云图片质量*/

let img_low = 300
let img_medium = 500
let img_high = 800
let img_veryHigh = 1500

let namespace = Bundle.main.infoDictionary!["CFBundleExecutable"] as! String

func SCFont(_ size : CGFloat, weight : UIFont.Weight) -> UIFont {
    var fontName = "PingFangSC"
    if weight == .regular {
        fontName = "PingFangSC-Regular"
    } else if weight == .medium {
        fontName = "PingFangSC-Medium"
    } else if weight == .semibold {
        fontName = "PingFangSC-Semibold"
    } else if weight == .thin {
        fontName = "PingFangSC-Thin"
    } else if weight == .light {
        fontName = "PingFangSC-Light"
    } else if weight == .ultraLight {
        fontName = "PingFangSC-Ultralight"
    }
    return UIFont(name: fontName, size: size) ?? UIFont.systemFont(ofSize: size, weight: weight)
}

// isIphoneX
var deviceIphoneX : Bool {
    get {
        return SCREEN_W == 375.0 && SCREEN_H == 812.0
    }
}
